﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ImportOrders
{
    /// <summary>
    /// Interaction logic for dlgSpecifications.xaml
    /// </summary>
    public partial class dlgSpecifications : Window
    {
        private SalesManagerEntities _sme = new SalesManagerEntities();

        public dlgSpecifications()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _sme.SaveChanges();
            }
            catch( Exception err )
            {
                MessageBox.Show("Error saving specifications.\n" + err.Message);
                return;
            }
            this.DialogResult = true;
            Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ((CollectionViewSource)FindResource("Specifications")).Source = (from c in _sme.tblImportSpec select c);
        }
    }
}
